package learning.maxent.training;

import java.util.ArrayList;
import java.util.List;

import learning.data.document.InstanceDocument;
import learning.maxent.training.Maxent.DecodingResult;


public class EvaluatorCV extends Evaluator {

	private List<Evaluator> evaluators;
	private List<MaxentParameters> parameters;
	
	public EvaluatorCV(Level level) {
		super(level);
		evaluators = new ArrayList<Evaluator>();
		parameters = new ArrayList<MaxentParameters>();
	}
	
	public void update(InstanceDocument doc, DecodingResult predictedParse, DecodingResult trueParse) {
		throw new UnsupportedOperationException();
	}
	
	public void update(Evaluator e, MaxentParameters params) {
		evaluators.add(e);
		super.errors.addAll(e.errors);
		super.totalDocuments += e.totalDocuments;
		super.documentErrors += e.documentErrors;
		for (int i=0; i < e.confusionMatrix.length; i++)
			for (int j=0; j < e.confusionMatrix[i].length; j++)
				super.confusionMatrix[i][j] += e.confusionMatrix[i][j];
		parameters.add(params);
	}
	
	public List<Evaluator> getRunEvaluators() {
		return evaluators;
	}
	
	public List<MaxentParameters> getRunParameters() {
		return parameters;
	}
}
